const { contextBridge } = require('electron')

contextBridge.exposeInMainWorld('versions', {
  node: () => process.versions.node,
  chrome: () => process.versions.chrome,
  electron: () => process.versions.electron
  // 除函数之外，我们也可以暴露变量

})
contextBridge.exposeInMainWorld('config',{
  server: "http://122.51.126.48:80",
  classCount:5,
  // 注意这里需要严格按照classCount来定
  scheme:[
    {start:"8:00",end:"9:40"},
    {start:"10:00",end:"11:30"},
    {start:"2:00",end:"4:00"},
    {start:"6:00",end:"7:30"},
    {start:"7:50",end:"9:00"}
  ],
})
contextBridge.exposeInMainWorld('utils',{
  uploadPicture:async function uploadPicture(file) {
  const formData = new FormData();
  formData.append('file', file);
  try {
    const response = await fetch('http://122.51.126.48:80/api/upload/picture', {
      method: 'POST',
      body: formData,
    });
    const data = await response.text();
    alert(data);
    return data; // 返回上传的响应数据
  } catch (error) {
    console.log('上传失败:', error);
    return null; // 返回 null
  }
},
 sayHello:function sayHello(){
  console.log("hello world")
 }
})



